package com.sphd.beautysalon.activitys;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;

import com.sphd.beautysalon.adapters.MyViewPagerAdapter;
import com.sphd.beautysalon.base.BaseActivity;
import com.sphd.beautysalon.fragments.EwmFragment;
import com.sphd.beautysalon.info.RestaurantInfo;
import com.sphd.beautysalon.utils.Constant;
import com.sphd.beautysalon.R;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 二维码分享
 */
public class ShareEwmActivity extends BaseActivity {

    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.my_vp)
    ViewPager myVp;
    List<Fragment> fragmentList;
    MyViewPagerAdapter myAdapter;
    String[] title = {"", ""};
    Intent intent;
    Bundle bundle;
    RestaurantInfo restaurantInfo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_share_ewm);
        ButterKnife.bind(this);
        initView();
        initEvent();
    }

    private void initEvent() {
        toolbar.setNavigationOnClickListener(v -> finish());
    }

    private void initView() {
        intent = getIntent();
        bundle = intent.getExtras();
        restaurantInfo = (RestaurantInfo) bundle.getSerializable(Constant.RESTAURANTSINFO);
        setTitleBar(toolbar, "分享");
        fragmentList = new ArrayList<>();
        myAdapter = new MyViewPagerAdapter(getSupportFragmentManager(), fragmentList, title);
        for (int i = 0; i < 1; i++) {
            EwmFragment ewmFragment = new EwmFragment();

            ewmFragment.setPageNo(i, restaurantInfo);

            fragmentList.add(ewmFragment);
        }
        myVp.setAdapter(myAdapter);

    }

}
